1. /* sdmstint.cpp by K.Tsuru */
  2. // function ID = 308 DRADIX, BRADIX
  3. // I changed it can treat number larger than BRADIX since ver 2.18.
  4. /********************************************************
  5. SDouble and SDecimal class
  6. It sets a short value.
  7. Usually "m=v" is all right. Please use in a large roop.
  8. ********************************************************/
  9. #ifndef SN_H
  10. #include "sn.h"
  11. #endif
  12. void SDouble::SetInt(int v){
  13. static const int F_SIZE = howdigsrdx(INT_MAX, DRADIX);
  14. static int* F = new int[F_SIZE];
  15. SetZero();
  16. // if(F_SIZE > minArraySize) Reserve(F_SIZE + 1); // 64 bits system
  17. if(v == 0) return;
  18. int absV = abs(v);
  19. SetSign(v);
  20. if(Type() == BIN_DEC){
  21. //for 32 bits system(always false in 16 bits system)
  22. if((double)absV >= BRADIX) SetError(OUT_OF_RANGE,"SD SetInt",308);
  23. figure[0] = (fType)absV;
  24. return;
  25. }
  26. int n = rdxconv(F, v, DRADIX);
  27. rdxExp = n; aTail = 1;
  28. int i, j;
  29. for(i = 1, j = n - 1 ; i <= n; i++, j--) {
  30. figure[i] = F[j];
  31. }
  32. for(i = n; figure[i] == 0; i--);
  33. aHead = i;
  34. /*
  35. if(absV < (int)DRADIX){
  36. figure[1] = (fType)absV;
  37. aHead = aTail = 1; rdxExp = 1;
  38. }else{
  39. figure[1] = fType(absV / (int)DRADIX);
  40. figure[2] = fType(absV % (int)DRADIX);
  41. aTail = 1; aHead = figure[2] ? 2 : 1;
  42. rdxExp = 2;
  43. }
  44. */
  45. }

sdmstint.cpp : last modifiled at 2017/03/13 14:31:58(1,320 bytes)
created at 2017/10/07 10:21:14
The creation time of this html file is 2017/10/07 10:30:03 (Sat Oct 07 10:30:03 2017).